package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.repository.entity.VendorProducts;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class VendorProductsVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "产品名称")
    private String name;

    @ApiModelProperty(value = "单位")
    private Integer unit;

    @ApiModelProperty(value = "单价")
    private BigDecimal onePrice;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "规格型号")
    private String specification;

    @ApiModelProperty(value = "材质")
    private String material;

    @ApiModelProperty(value = "单位名称")
    private String unitName;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static VendorProducts convert(VendorProductsVO vo) {
        VendorProducts entity = new VendorProducts();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<VendorProducts> convertList(List<VendorProductsVO> list) {
        List<VendorProducts> resultList = new ArrayList<>();
        for (VendorProductsVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
